In [1]:
import jwstniriss as jw
import numpy as np #numpy gives us better array management
In [2]:
import matplotlib #ploting
matplotlib.use("Agg") #some hack to stop the bouncing python icon when plotting
import matplotlib.pyplot as plt
#next line is to show plots inline with jupyter
#%matplotlib inline
from matplotlib.colors import LogNorm #for better display of FITS images
In [3]:
%matplotlib inline
In [4]:
jw.read_datacube.__doc__
Out[4]:
In [5]:
jw.r2s.__doc__
Out[5]:
In [6]:
jw.apertureflux.__doc__
Out[6]:
In [7]:
jw.tracespec.__doc__
Out[7]:
In [8]:
scidata=jw.read_datacube("samples/cube-700-CLR.fits")
In [24]:
plt.figure(figsize=(20,4)) #adjust size of figure
imgplot = plt.imshow(np.transpose(scidata[4,:,:]),norm=LogNorm())
plt.axis((0,image.shape[0],0,image.shape[1]))
plt.show()
In [10]:
zpt,slope,image=jw.r2s(scidata)
In [23]:
plt.figure(figsize=(20,4)) #adjust size of figure
imgplot = plt.imshow(np.transpose(zpt),norm=LogNorm())
plt.axis((0,image.shape[0],0,image.shape[1]))
plt.show()
In [22]:
plt.figure(figsize=(20,4)) #adjust size of figure
imgplot = plt.imshow(np.transpose(image),norm=LogNorm())
plt.axis((0,image.shape[0],0,image.shape[1]))
plt.show()
In [19]:
tr, trpsf = jw.tracespec(image) #run the trace program to find the n=1 spectrum
#tr contains the trace for each order, trpsf contains the model parameters from the PSF fit.
In [25]:
plt.figure(figsize=(20,4)) #adjust size of figure
imgplot = plt.imshow(np.transpose(image),norm=LogNorm()) #added log stretch to the plot
#imgplot = plt.colorbar() #add colour bar
plt.plot(tr[:,0],c='b') #overlay trace for n=1
plt.xlabel('Column (pixel)') #x-label
plt.ylabel('Row (pixel)') #y-label
x1,x2,y1,y2 = plt.axis()
plt.axis((0,image.shape[0],0,image.shape[1]))
plt.show()
In [29]:
flux=jw.apertureflux(image,tr,20,0) #extract the flux along the trae using a simple aperture
In [33]:
plt.figure(figsize=(16,4)) #adjust size of figure
plt.plot(np.sum(image,axis=1),label='Column Sum') #Plot the sum of each column
plt.plot(flux,c='r',label='Aperture Sum') #Plot the sum of each column
plt.xlabel('Column (pixel)') #x-label
plt.ylabel('Counts') #y-label
x1,x2,y1,y2 = plt.axis()
x1=0
x2=image.shape[0]
y1=0
plt.axis((x1,x2,y1,y2))
plt.legend()
plt.show()
In [ ]: